package com.vivien.example.springbootdemo.controller;

import com.vivien.example.springbootdemo.pojo.OrderRequest;
import com.vivien.example.springbootdemo.service.OrderService;
import com.vivien.example.springbootdemo.vo.DataResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class PersonOrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/order/list")
    public DataResult getOrderList(@RequestBody OrderRequest orderRequest){
        DataResult r=new DataResult();
        r.setCode("0");
        r.setMessage("success");
        r.setData(orderService.getOrderList(orderRequest));
        return r;
    }

    @GetMapping("/order/detail")
    public DataResult getOrderById(@RequestParam(name="orderId") String orderId){
        System.out.println(orderId);
        DataResult r=new DataResult();
        r.setCode("0");
        r.setMessage("success");
        r.setData(orderService.getOrderById(orderId));
        return r;
    }
}
